package temperatureTrend;

public class Solution {
    public int temperatureTrend(int[] temperatureA, int[] temperatureB) {
        // 天数最长的
        int ans = 0;
        int l = 0,r = 1;
        while (r<temperatureA.length) {
            // 比较两地的气温变化趋势
            int a = temperatureA[r] - temperatureA[r-1];
            int b = temperatureB[r] - temperatureB[r-1];
            if(a<0&&b<0) {
                ans = Math.max(ans,r-l);
            } else if(a>0&&b>0) {
                ans = Math.max(ans,r-l);
            } else if(a==0&&b==0) {
                ans = Math.max(ans,r-l);
            }else {
                l = r;
            }
            r++;
        }
        return ans;
    }
}